package com.jsle.common.artifactory;

import java.util.Locale;

import org.springframework.context.ApplicationContext;

/**
 * spring context util
 * @author wisdying
 * @date 2012-11-10
 */
public class ContextUtil {

	private static final ContextUtil instance = new ContextUtil();
	private static ApplicationContext context;
	private static Locale locale;
	
	private ContextUtil(){
		//todo...
	}
	public static ContextUtil getInstance(){
		return instance;
	}
	
	@SuppressWarnings("static-access")
	public synchronized void setApplicationContext(ApplicationContext context) {
		this.context = context;
	}

	public static ApplicationContext getApplicationContext() {
		return context;
	}
	
	public static Locale getLocal() {
		return locale;
	}

	public static void setLocal(Locale local) {
		ContextUtil.locale = locale;
	}
	
	@SuppressWarnings("static-access")
	public static Object getBean(String name){
		return ContextUtil.getInstance().getApplicationContext().getBean(name);
	}
}
